<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('工资条列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>日期：</label>
                                <input type="text" class="time-input" data-type="month" id="years" placeholder="日期" name="params[years]"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('gcgl:gzt:edit')}]];
        var prefix = ctx + "gcgl/gztcz";
        var datas = [[${@dict.getType('gcgl_hx_status')}]];

        $(function() {
            var options = {
                url: prefix + "/cwpslist",
                updateUrl: prefix + "/edit/{id}",
                exportUrl: prefix + "/export",
                modalName: "工资条",
                sortName: "id desc",
                sortOrder: "",
                columns: [{
                    field: 'years',
                    title: '日期'
                },
                {
		            field: 'status',
		            title: '状态',
		            align: "left",
		            formatter: function(value, item, index) {
		            	return $.table.selectDictLabel(datas, item.status);
		            }
		        },
		        {
                    field: 'cwsh',
                    title: '财务审核'
                },
                {
                    field: 'cwshAt',
                    title: '财务审核时间'
                },
                {
                    field: 'zjlsb',
                    title: '总经理批准'
                },
                {
                    field: 'zjlsbAt',
                    title: '总经理批准时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="gztEdit(\'' + row.years + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-info btn-xs" href="javascript:void(0)" onclick="gztOk(\'' + row.years + '\')"><i class="fa fa-check"></i>审核通过</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="gztCannel(\'' + row.years + '\')"><i class="fa fa-remove"></i>审核拒绝</a> ');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
        function gztEdit(years){
            $.modal.openTab('工资表人员信息',"/gcgl/gztcz/gztItem/"+years);
        }
        
        function gztOk(years){
	    	$.modal.confirm("确认要审核通过吗?", function() {
	    		$.ajax({
    				url: "/gcgl/gztcz/cwyes",
    				type: "post",
    				data: { "years": years },
    				dataType: 'json',
    				success: function(data) {
    					$.table.refresh();
    				},
    				error: function(xhr, type, errorThrown) {
    					//异常处理；
    					$.modal.alert("请稍后再试！");
    					$.table.refresh();
    				}
    			});
	    	});
	    }
	    
	    function gztCannel(years){
	    	$.modal.confirm("确认要审核拒绝吗?", function() {
	    		$.ajax({
    				url: "/gcgl/gztcz/cwno",
    				type: "post",
    				data: { "years": years },
    				dataType: 'json',
    				success: function(data) {
    					$.table.refresh();
    				},
    				error: function(xhr, type, errorThrown) {
    					//异常处理；
    					$.modal.alert("请稍后再试！");
    					$.table.refresh();
    				}
    			});
	    	});
	    }
    </script>
</body>
</html>